#include "thread_pool.hpp"
#include "task.hpp"
#include <cstdlib>
#include <ctime>
#include <unistd.h>
#include <string>

using namespace ns_thread_pool;
using namespace ns_task;

//void Test(ThreadPool<Task>* tp)
void Test()
{
    ThreadPool<Task>* tp = ThreadPool<Task>::GetInstance();
    while(true)
    {
        std::string s = "+-*/%";
        int left = rand() % 20 + 1;
        int right = rand() % 10 + 1;
        char op = s[rand() % 5];
        Task t(left, right, op);
        //int t = rand() % 20;
        tp->push(t);
        std::cout << "生产的数据是 " << left << op << right << "=?" << std::endl;
        //std::cout << "生产者生产的数据是 " << t << std::endl;
        //sleep(1);
    }
}

int main()
{
    srand(time(nullptr));
    //ThreadPool<Task>* tp = new ThreadPool<Task>();
    //tp->InitThreadPool();
    //Test(tp);
    Test();

    return 0;
}